package cn.cutie.clotcache.command;

import cn.cutie.clotcache.core.ClotCache;
import cn.cutie.clotcache.core.Command;
import cn.cutie.clotcache.core.Reply;

/**
 * @Description:
 * @Author: Cutie
 * @CreateDate: 2024/6/20 14:21
 * @Version: 0.0.1
 */
public class LrangeCommand implements Command {
    @Override
    public String name() {
        return "LRANGE";
    }

    @Override
    public Reply<?> exec(ClotCache cache, String[] args) {
        String key = getKey(args);
        String[] params = getParamsNoKey(args);
        int start = Integer.parseInt(params[0]);
        int end = Integer.parseInt(params[1]);
        return Reply.array(cache.lrange(key, start, end));
    }
}
